package com.tingyuge.base.structrue.node;

import sun.swing.plaf.synth.DefaultSynthStyle;

/**
 * @Created by xiaodao
 */
public class Sum {

    public static void main(String[] args) {
        int[] a = {1,2,3,4,5,10};
        System.out.println(sum(a));
    }


    public static int sum(int[] arr){
        return sum(arr,0);
    }

    private static int sum(int[] arr, int index){
        if(index == arr.length){
            return 0;
        }else{
            return arr[index]+ sum(arr,index+1);
        }
    }
}
